package com.local.webservice;

import com.local.webservice.service.HelloWorld;
import com.local.webservice.service.impl.HelloWorldImpl;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import javax.xml.ws.Endpoint;

/**
 * @author lou ke
 * @version 1.0
 * @since 2020/5/8 14:22
 */

/**
 * jdk 实现:  暴露 webservice 接口
 */
public class Server {
    public static void main(String[] args) {
        System.out.println("web service start...");
        // 实现类
        HelloWorld implementor = new HelloWorldImpl();
        // 地址
        String address = "http://127.0.0.1:8000/helloworld";
        // 发布 jdk 实现
        // Endpoint.publish(address, implementor);

        // cxf 实现
        JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
        factoryBean.setAddress(address);  // 设置暴露地址
        factoryBean.setServiceClass(HelloWorld.class); //接口类
        factoryBean.setServiceBean(implementor); // 实现类
        factoryBean.create(); // 创建 webservice 接口

        System.out.println("web service started...");
    }
}
